#include<func.h>
#include<sys/mman.h>
#include<ctype.h>
int main(int argc,char*argv[])
{
    //./homework05 file2
    ARGS_CHECK(argc,2);
    int fd = open(argv[1],O_RDWR);
    ERROR_CHECK(fd,-1,"open");
    //使用mmap
    //获取文件总长度
    off_t size = lseek(fd,0,SEEK_END);
    char*p = (char*)mmap(NULL,size,PROT_READ|PROT_WRITE,MAP_SHARED,fd,0);
    ERROR_CHECK(p,MAP_FAILED,"mmap");

    for(off_t i = 0;i<size;i++)
    {
        if(p[i]>='a'&& p[i]<='z')
        {
            //切换大小写
            p[i] = p[i]-32;
        }
        if(ispunct(p[i]))
        {
            p[i]=' ';
        }
    }
    close(fd);
    munmap(p,size);
    return 0;
}